﻿//* reference:  listview:http://www.cnblogs.com/zhihai/archive/2012/02/03/2337052.html

using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using uTrade.Common;
using uTrade.Data;
using uTrade.Views;

namespace uTrade
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        private FundModel fdModle = new FundModel();
        private readonly GetFundbyName getuTrade = new GetFundbyName();
        private readonly GetFundDetailInfo getMyDetail = new GetFundDetailInfo();
        private List<EquityModel> ntWorkModel = new List<EquityModel>();
        private PriceInfo fdpInfo;

        public MainWindow()
        {
            InitializeComponent();
            //try
            {
                fdpInfo = GetFundEquityInfo.GetFormatedFundInfo("160631", DateService.ThisTimeLastYear(), DateTime.Now);
                //TransDatas transBars = dataAccessService.GetData("a_000", DateTime.Now.AddDays(-10), DateTime.Now);

                //oFundPanel.Load(transBars);
            }
            //catch
            { }

            LogHelper.Write(LogHelper.LogLevel.Info, "djkdjk");

            //DataAccessFromTdx oTdxAccess = new DataAccessFromTdx();
            //oTdxAccess.DataAccessBackGround();
            //TdxTest tdxTest = new TdxTest();
            //tdxTest.TdxAPITest();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
        }

        private void BtnSearch_Click(object sender, RoutedEventArgs e)
        {
            if (tbxSrhContent.Text == "")
            {
                return;
            }
            fdModle = (FundModel)getuTrade.GetFundByName(tbxSrhContent.Text);
            lvFundName.ItemsSource = fdModle.Datas;
        }

        private void Win_FundDteail_ItemDoubleClick(object sender, ItemkArgs e)
        {
            Rank dRank = e.RankItem;
            string symbol = dRank.Symbol;
            fdpInfo = GetFundEquityInfo.GetFormatedFundInfo(symbol, DateService.ThisTimeLastYear(), DateTime.Now);

            //oFundPanel.Load(fdpInfo);
            tbctrl_MainTab.SelectedIndex = 0;
        }

        private void LvFundName_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Fund cfund = lvFundName.SelectedItem as Fund;
            ntWorkModel = GetFundEquityInfo.Info(cfund.CODE, DateService.ThisTimeLastYear(), DateTime.Now);
            lvLatestNet.ItemsSource = ntWorkModel;
            getMyDetail.GetGuessInfo(GetFundEquityInfo.InfoEqLst(ntWorkModel));
            lvReferInfo.ItemsSource = getMyDetail.Datas;
        }

        private void Mit_About_Click(object sender, RoutedEventArgs e)
        {
            AboutView abWin = new AboutView();
            abWin.ShowDialog();
        }
    }
}